;
(function () {

  'use strict';

  angular.module('directives.customActivity')
    .directive('summaryBusVolumeLayout', summaryBusVolumeLayout)
    .directive('summaryFailVolumeLayout', summaryFailVolumeLayout)
    .directive('summarySuccessVolumeLayout', summarySuccessVolumeLayout)
    .directive('summaryTopUpPrefer', summaryTopUpPrefer)
    .directive('summaryTotalRatio', summaryTotalRatio)
    .directive('summaryTotalRatioLayout', summaryTotalRatioLayout)
    .directive('summaryTopUpPreferLayout', summaryTopUpPreferLayout)
    .directive('summaryBusVolumeContrastive', summaryBusVolumeContrastive)
    .directive('summaryBusLineRatioLayout', summaryBusLineRatioLayout)
    .directive('summaryBusVolumeContrastiveLayout', summaryBusVolumeContrastiveLayout);

  function summaryBusLineRatioLayout(summaryBusLineRatioService) {

    return {
      retrict: 'E',
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-bus-line-ratio-layout">' +
      '<label class="title title-color2">各业务线交易占比</label>' +
      '<div class="center"></div>' +
      '<core-loading ng-hide="info.loading"></core-loading>' +
      '</div>',
      replace: true,
      link: function (scope, element) {
        scope.info = summaryBusLineRatioService;
        summaryBusLineRatioService.init(element.find('div')[0]);
      }
    };
  }

  summaryBusLineRatioLayout.$inject = ['summaryBusLineRatioService'];

  function summaryBusVolumeContrastiveLayout() {

    return {
      retrict: 'E',
      template: '<div layoutdom="2" draggable="true" class="model" module-name="summary-bus-volume-contrastive-layout">' +
      '<label class="title title-color2">交易量与去年同期对比</label>' +
      '<div slider slider-include="summary-bus-volume-contrastive"></div>' +
      '</div>',
      replace: true
    };
  }

  function summaryTopUpPreferLayout() {

    return {
      retrict: 'E',
      template: '<div layoutdom="2" draggable="true" class="model model2" module-name="summary-top-up-prefer-layout">' +
      '<label class="title title-color2">用户充值偏好</label>' +
      '<div slider slider-include="summary-top-up-prefer"></div>' +
      '</div>',
      replace: true
    };
  }

  function summaryBusVolumeContrastive(summaryBusVolumeContrastiveService) {

    return {
      restrict: 'A',
      template: '<div class="grap"></div>' +
      '<div class="clearfix summaryBusVolumeContrastiveTitle"><div class="left">今年业务量（笔）</div><div class="right">去年业务量（笔）</div></div>' +
      '<div class="table-head">' +
      '<table class="table table-bordered"><thead>' +
      '<tr>' +
      '<th width="25%">日期</th>' +
      '<th width="25%">今年业务量</th>' +
      '<th width="25%">去年业务量</th>' +
      '<th width="25%">同比增长率</th>' +
      '</tr>' +
      '</thead>' +
      '</table>' +
      '</div>' +
      '<div class="table-body">' +
      '<table class="table table-bordered">' +
      '<tbody>' +
      '<tr ng-repeat="d in data.list[sys]">' +
      '<td width="25%">{{d.date}}</td>' +
      '<td width="25%">{{d.thisYearBusVolume}}</td>' +
      '<td width="25%">{{d.lastYearBusVolume}}</td>' +
      '<td width="25%">{{d.growthRate|fixedFilter:2}}%</td>' +
      '</tr>' +
      '</tbody>' +
      '</table>' +
      '<core-loading ng-hide="data.loading"></core-loading>' +
      '</div>',
      scope: true,
      link: function (scope, element, attrs) {
        scope.data = summaryBusVolumeContrastiveService;
        scope.sys = attrs.summaryBusVolumeContrastive;
        summaryBusVolumeContrastiveService.init(attrs.summaryBusVolumeContrastive, element.find('div'));
      }
    };
  }

  summaryBusVolumeContrastive.$inject = ['summaryBusVolumeContrastiveService'];

  function summaryBusVolumeLayout(summaryBusVolumeService) {

    return {
      restrict: 'E',
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-bus-volume-layout">' +
      '<label class="title title-color2">{{title}}</label>' +
      '<div class="center">' +
      '<table class="toptable">' +
      '<tr ng-if="busVolume.UPAYS">' +
      '<td>统一支付</td>' +
      '<td>{{busVolume.UPAY | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.TMALLS">' +
      '<td>天猫旗舰店</td>' +
      '<td>{{busVolume.TMALL | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.SCPAYS">' +
      '<td>移动商城</td>' +
      '<td>{{busVolume.SCPAY | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.BANKS">' +
      '<td>银行总对总</td>' +
      '<td>{{busVolume.BANK | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.VCESS">' +
      '<td>有价卡</td>' +
      '<td>{{busVolume.VCES | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.LINGXIS">' +
      '<td>灵犀语音</td>' +
      '<td>{{busVolume.LINGXI | number: 0}}</td>' +
      '</tr>' +
      '</table>' +
      '</div>' +
      '<core-loading ng-hide="busVolume.loading"></core-loading>' +
      '</div>',
      scope: true,
      replace: true,
      link: function (scope) {
        scope.busVolume = summaryBusVolumeService;
        scope.title = '活动期间累计业务量';
        summaryBusVolumeService.init();
      }
    }
  }

  summaryBusVolumeLayout.$inject = ['summaryBusVolumeService'];

  function summaryFailVolumeLayout(summaryFailVolumeService) {

    return {
      restrict: 'E',
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-fail-volume-layout">' +
      '<label class="title title-color2">{{title}}</label>' +
      '<div class="center">' +
      '<table class="toptable">' +
      '<tr ng-if="busVolume.UPAYS">' +
      '<td>统一支付</td>' +
      '<td>{{busVolume.UPAY | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.TMALLS">' +
      '<td>天猫旗舰店</td>' +
      '<td>{{busVolume.TMALL | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.SCPAYS">' +
      '<td>移动商城</td>' +
      '<td>{{busVolume.SCPAY | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.BANKS">' +
      '<td>银行总对总</td>' +
      '<td>{{busVolume.BANK | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.VCESS">' +
      '<td>有价卡</td>' +
      '<td>{{busVolume.VCES | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.LINGXIS">' +
      '<td>灵犀语音</td>' +
      '<td>{{busVolume.LINGXI | number: 0}}</td>' +
      '</tr>' +
      '</table>' +
      '</div>' +
      '<core-loading ng-hide="busVolume.loading"></core-loading>' +
      '</div>',
      scope: true,
      replace: true,
      link: function (scope) {
        scope.busVolume = summaryFailVolumeService;
        scope.title = '活动期间累计失败量';
        summaryFailVolumeService.init();
      }
    }
  }

  summaryFailVolumeLayout.$inject = ['summaryFailVolumeService'];

  function summarySuccessVolumeLayout(summarySuccessVolumeService) {

    return {
      restrict: 'E',
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-success-volume-layout">' +
      '<label class="title title-color2">{{title}}</label>' +
      '<div class="center">' +
      '<table class="toptable">' +
      '<tr ng-if="busVolume.UPAYS">' +
      '<td>统一支付</td>' +
      '<td>{{busVolume.UPAY | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.TMALLS">' +
      '<td>天猫旗舰店</td>' +
      '<td>{{busVolume.TMALL | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.SCPAYS">' +
      '<td>移动商城</td>' +
      '<td>{{busVolume.SCPAY | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.BANKS">' +
      '<td>银行总对总</td>' +
      '<td>{{busVolume.BANK | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.VCESS">' +
      '<td>有价卡</td>' +
      '<td>{{busVolume.VCES | number: 0}}</td>' +
      '</tr>' +
      '<tr ng-if="busVolume.LINGXIS">' +
      '<td>灵犀语音</td>' +
      '<td>{{busVolume.LINGXI | number: 0}}</td>' +
      '</tr>' +
      '</table>' +
      '</div>' +
      '<core-loading ng-hide="busVolume.loading"></core-loading>' +
      '</div>',
      scope: true,
      replace: true,
      link: function (scope) {
        scope.busVolume = summarySuccessVolumeService;
        scope.title = '活动期间累计成功量';
        summarySuccessVolumeService.init();
      }
    }
  }

  summarySuccessVolumeLayout.$inject = ['summarySuccessVolumeService'];

  function summaryTotalRatioLayout() {

    return {
      retrict: 'E',
      template: '<div layoutdom="2" draggable="true" class="model" module-name="summary-total-ratio-layout">' +
      '<label class="title title-color2">活动期间交易总量占比</label>' +
      '<div slider slider-include="summary-total-ratio"></div>' +
      '</div>',
      replace: true
    };
  }

  function summaryTotalRatio(summaryTotalRatioService) {

    return {
      restrict: 'A',
      template: '<div class="center"></div>' +
      '<div>{{sys | busLineFilter}}</div>' +
      '<core-loading ng-hide="info.loading"></core-loading>',
      scope: true,
      link: function (scope, element, attrs) {
        scope.info = summaryTotalRatioService;
        scope.sys = attrs.summaryTotalRatio;
        summaryTotalRatioService.queryBySys(attrs.summaryTotalRatio, element.find('div'));
      }
    }
  }

  summaryTotalRatio.$inject = ['summaryTotalRatioService'];


  function summaryTopUpPrefer(summaryTopUpPreferService) {

    return {
      restrict: 'A',
      template: '<div class="center" style="height: 180px;"></div><span class="jyl">交易量（{{info[sys]}}）</span><core-loading ng-hide="info.loading"></core-loading>',
      scope: true,
      link: function (scope, element, attrs) {
        scope.info = summaryTopUpPreferService;
        scope.sys = attrs.summaryTopUpPrefer;
        summaryTopUpPreferService.queryBySys(attrs.summaryTopUpPrefer, element.find('div'));
      }
    }
  }

  summaryTopUpPrefer.$inject = ['summaryTopUpPreferService'];
})();